package com.qsboss.demo.quartz;

import cn.hutool.core.util.RandomUtil;
import com.qsboss.demo.pojo.TbBill;
import com.qsboss.demo.service.TbBillService;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * @author 军哥
 * @version 1.0
 * @description: 生成随机账单的任务
 * @date 2023/10/27 10:00
 */

public class RandomBillTask {

    @Autowired
    TbBillService tbBillService;

    public void randomBill() {
        System.out.println("生成随机账单~~~~~");

        TbBill tbBill = tbBillService.randomBill();

        TbBill bill = new TbBill();
        bill.setBillName(tbBill.getBillName());

        double randomNumber = (double)RandomUtil.randomInt(1, 10000);
        double amount = randomNumber/100;

        bill.setBillAmount(amount);
        bill.setOptId(tbBill.getOptId());
        bill.setOptName(tbBill.getOptName());
        bill.setCustomerId(tbBill.getCustomerId());
        bill.setCustomerName(tbBill.getCustomerName());

        tbBillService.addBill(bill);
    }

}
